import 'package:FlutterReader/reading/reader/reader_screen.dart';
import 'package:FlutterReader/router/context_extension.dart';
import 'package:flutter/material.dart';
import 'clickable.dart';

class ShowNovelTest extends StatelessWidget {
  final bool isEven;
  final int index;
  final VoidCallback? onTap;
  final String title = "这里是文字说明";
  final double heightC;

   ShowNovelTest({
    super.key,
    required this.isEven, required this.index, this.onTap, required this.heightC,
  });

  @override
  Widget build(BuildContext context) {
    final theme = Theme.of(context);

    return Clickable(
      backgroundColor: theme.colorScheme.surface,
      onTap: ()=> context.routeTo(ReaderScreen),
      onLongPress: (Offset offset, BuildContext context) {  },
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          if(heightC == 0) ...[
            Expanded(
              child: Container(
                // constraints: BoxConstraints(
                //   minHeight: 0, // 设置最小高度约束
                //   maxHeight: 250, // 设置最大高度约束
                // ),
                height: heightC != 0 ? heightC : null, // 更明确的默认行为
                margin: const EdgeInsets.all(5), // 外边距
                decoration: BoxDecoration(
                  color: isEven ? Colors.blue : Colors.green,
                  borderRadius: BorderRadius.circular(8),
                  boxShadow: [
                    BoxShadow(
                      color: Colors.black,
                      blurRadius: 4,
                      offset: Offset(2, 2),
                    )
                  ],
                ),
                child: Center(
                  child: Text(
                    '样例展示 $index',
                    style: TextStyle(
                      color: Colors.white,
                      fontSize: 16,
                      fontWeight: FontWeight.bold,
                    ),
                  ),
                ),
              ),
            ),
          ] else ...[
            Container(
              // constraints: BoxConstraints(
              //   minHeight: 0, // 设置最小高度约束
              //   maxHeight: 250, // 设置最大高度约束
              // ),
              height: heightC != 0 ? heightC : null, // 更明确的默认行为
              margin: const EdgeInsets.all(5), // 外边距
              decoration: BoxDecoration(
                color: isEven ? Colors.blue : Colors.green,
                borderRadius: BorderRadius.circular(8),
                boxShadow: [
                  BoxShadow(
                    color: Colors.black,
                    blurRadius: 4,
                    offset: Offset(2, 2),
                  )
                ],
              ),
              child: Center(
                child: Text(
                  '样例展示 $index',
                  style: TextStyle(
                    color: Colors.white,
                    fontSize: 16,
                    fontWeight: FontWeight.bold,
                  ),
                ),
              ),
            ),
            Text("$title"),
            Text("这里是章节描述",style: TextStyle(fontSize: 8),),
            SizedBox(height: 20,),
          ]
        ],
      )
    );
  }
}
